#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    int minSwapsCouples(vector<int>& row) {
        //这题可以采用贪心加异或运算
        int result = 0;
        for(int i = 0; i<row.size(); i=i+2){
            int temp = row[i]^1;
            if(temp == row[i+1]){
                continue;
            }
            else{
                result = result+1;
                auto index = find(row.begin()+i,row.end(),temp);
                *index = row[i+1];
            }
        }
        return result;
    }
};

int main(){
    Solution S;
    vector<int> row = {3,2,0,1};
    cout<<S.minSwapsCouples(row)<<endl;
}